/*
 * Memory Setup stuff - taken from blob memsetup.S
 *
 * Copyright (C) 1999 2000 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) and
 *                     Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl)
 *
 * Modified for the Samsung SMDK2410 by
 * (C) Copyright 2002
 * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch>
 *
 * SPDX-License-Identifier:	GPL-2.0+
 */


#include <config.h>

/* some parameters for the board */

#define BWSCON	0x48000000

.globl lowlevel_init
lowlevel_init:
	/* memory control configuration */
	/* make r0 relative the current location so that it */
	/* reads SMRDATA out of FLASH rather than memory ! */
	ldr     r0, =SMRDATA
	ldr	r1, =CONFIG_SYS_TEXT_BASE
	sub	r0, r0, r1
	ldr	r1, =BWSCON	/* Bus Width Status Controller */
	add     r2, r0, #13*4
0:
	ldr     r3, [r0], #4
	str     r3, [r1], #4
	cmp     r2, r0
	bne     0b

	/* everything is fine now */
	mov	pc, lr

	.ltorg
/* the literal pools origin */

SMRDATA:
    .word 0x22011110  @ BWSCON
    .word 0x00000700  @ BANKCON0
    .word 0x00000700  @ BANKCON1
    .word 0x00000700  @ BANKCON2
    .word 0x00000700  @ BANKCON3
    .word 0x00000700  @ BANKCON4
    .word 0x00000700  @ BANKCON5
    .word 0x00018005  @ BANKCON6
    .word 0x00018005  @ BANKCON7
    .word 0x008C07A3  @ REFRESH
    .word 0x000000B1  @ BANKSIZE
    .word 0x00000030  @ MRSRB6
    .word 0x00000030  @ MRSRB7
